Skip to content

Add opt-in indexed search continuity - #1027

Draft
eseliger wants to merge 13 commits into
mainfrom
indexed-search-continuity
Draft

eseliger wants to merge 13 commits into
mainfrom
indexed-search-continuity

Conversation

@eseliger

@eseliger eseliger commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Adds opt-in indexed search continuity to the chart behind indexedSearch.continuity.enabled, which defaults to false. With it off, helm template renders byte-identical manifests to this branch's base on main.

Continuity is a new indexed search architecture being prototyped in sourcegraph/sourcegraph: stateless indexers publish each repository's index generations to object storage, webservers download them and activate new versions only once enough replicas have them, and the frontend searches each repository on exactly one ready replica. This chart change is a draft: the continuity images (zoekt-continuity-webserver, zoekt-continuity-indexer) and the application settings it relies on (SRC_INDEXED_SEARCH_CONTINUITY_ROUTING, SRC_INDEXED_SEARCH_CONTINUITY_WEBSERVERS) aren't released yet.

Side-by-side design

Continuity runs as a separate fleet next to the existing indexed-search StatefulSet, with different workload, Service, and PVC names, so an existing instance can switch over without users noticing. indexed-search (StatefulSet, indexed-search and indexed-search-indexer Services, PDB, ServiceAccount) renders exactly as on main whether continuity is on or off.

Enabling continuity adds:

  • indexed-searcher StatefulSet and headless Service: one zoekt-continuity-webserver container per pod (gRPC 6070, metrics 6060). Readiness GET /ready, liveness GET /healthz, OrderedReady, rolling updates, 60 s termination grace period, its own data PVCs. Prometheus scrapes port 6060. The frontend's default continuity endpoint, k8s+rpc://indexed-searcher:6070?kind=sts, finds it, so the chart doesn't set SRC_INDEXED_SEARCH_CONTINUITY_WEBSERVERS. Optional PDB and ServiceAccount, like indexed-search. Configured under a new top-level indexedSearcher block modelled on indexedSearch.
  • indexed-searcher-indexer Deployment (2 replicas, emptyDir scratch) plus a headless metrics Service on 6060. Named so it doesn't collide with the old fleet's indexed-search-indexer Service. Uses indexedSearcher's scheduling, security context, and ServiceAccount settings; its own settings stay under indexedSearch.continuity.indexer.
  • frontend, worker, searcher, gitserver (and the continuity pods): SRC_INDEXED_SEARCH_CONTINUITY_ENABLED, _ROUTING, _WARM_REPLICAS, _ACTIVATION_TOLERANCE, _REPLICATION_FACTORS, plus indexedSearch.continuity.env. Their settings for the old fleet are unchanged.

New values:

  • indexedSearch.continuity.routing (default true) sets SRC_INDEXED_SEARCH_CONTINUITY_ROUTING. false keeps searches on indexed-search while continuity indexes and warms.
  • indexedSearch.enabled (default true) gates every indexed-search object, so the old fleet can be removed after the switch.
  • indexedSearcher.* for the webservers (the former indexedSearch.continuity.webserverImage, webserverCommand/webserverArgs, and terminationGracePeriodSeconds moved here as image, command/args, terminationGracePeriodSeconds).

Validation: indexedSearch.continuity.replicas must not exceed indexedSearcher.replicaCount; activationTolerance must be less than replicas; indexedSearcher.terminationGracePeriodSeconds at least 30; routing: false is rejected when indexedSearch.enabled is false, since searches would go to the removed fleet.

The frontend Role already allows get/list/watch on endpoints and statefulsets in the namespace, which covers kind=sts discovery of indexed-searcher.

Migration

  1. Set indexedSearch.continuity.enabled: true and indexedSearch.continuity.routing: false. The new fleet runs next to indexed-search, indexes every repository from scratch, and warms its webservers; searches still go to indexed-search.
  2. Wait for the worker metric src_zoekt_continuity_ready_to_route to be 1 (every indexable repository has an active generation and every slot is ready on its whole placement).
  3. Set indexedSearch.continuity.routing: true. Searches go to indexed-searcher.
  4. Set indexedSearch.enabled: false to remove the indexed-search StatefulSet, then delete its data-indexed-search-* PVCs, which Kubernetes keeps after a StatefulSet is deleted.

New installations set indexedSearch.enabled: false with continuity enabled and routing true. Both paths are documented in the README's new "Indexed search continuity" section.

Test plan

  • helm unittest charts/sourcegraph: 43 suites, 277 tests pass, including tests/indexedSearchContinuity_test.yaml (default renders no continuity objects and the old layout; both fleets with distinct names; indexedSearcher settings; routing reaches env; indexedSearch.enabled: false removes the old objects; validation failures).
  • helm lint charts/sourcegraph passes with continuity off, on with routing off, and on with indexedSearch.enabled: false.
  • helm template with continuity off is byte-identical to the merge base with main; against current main only the release image tags and chart version differ (the branch predates the v8.2.1283 bump). With continuity on, the indexed-search objects render identically to continuity off.
  • An earlier revision of this chart ran continuity in a kind cluster (3 webservers, 2 indexers) with rolling restarts and scale up/down under load. The side-by-side layout hasn't run in a cluster yet.

indexedSearch.continuity.enabled replaces the zoekt-webserver and
zoekt-indexserver containers with one continuity webserver per
indexed-search pod, adds an indexer Deployment that publishes shards
through object storage, and passes the continuity settings to frontend,
worker, searcher, and gitserver. Off by default; disabled renders are
unchanged.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
@github-actions

Copy link
Copy Markdown

Continuity no longer swaps the indexed-search containers in place. It
runs as its own fleet, so an instance can index every repository and
warm the new webservers before searches move to them:

- indexed-searcher StatefulSet and headless Service (plus optional PDB
  and ServiceAccount) run zoekt-continuity-webserver, configured under
  a new top-level indexedSearcher block. The frontend's default
  continuity endpoint, k8s+rpc://indexed-searcher:6070?kind=sts, finds
  them without extra settings.
- The indexer Deployment and metrics Service are now
  indexed-searcher-indexer, so they no longer collide with the old
  fleet's indexed-search-indexer Service.
- indexedSearch.continuity.routing (default true) sets
  SRC_INDEXED_SEARCH_CONTINUITY_ROUTING. Migrating instances set it to
  false until src_zoekt_continuity_ready_to_route is 1.
- indexedSearch.enabled (default true) gates every indexed-search
  object, so the old fleet can be removed after the switch.

indexed-search renders exactly as before; with continuity off the whole
chart renders unchanged.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
Switching indexedSearch.continuity.routing restarted the indexed-searcher webservers,
the indexers and gitserver, none of which read SRC_INDEXED_SEARCH_CONTINUITY_ROUTING.
On kind the routing flip then rolled the new webservers at the same moment the
frontends started routing to them. Render the variable only for the frontend, worker
and searcher.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
A starting webserver stays unready until it has loaded all its slots,
so a rolling restart waits for it, but it serves each slot as soon as
that slot is loaded. Publishing its address while it is unready lets the
frontend route those slots meanwhile.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
Follows sourcegraph/sourcegraph#20044, which drops the continuity name:

- Values: indexedSearch.continuity becomes zoekt, indexedSearcher becomes
  zoektSearcher.
- Workloads and images: zoekt-indexer and zoekt-searcher.
- Environment: SRC_ZOEKT_INDEXER_ENABLED, SRC_ZOEKT_SEARCHER_ROUTING and
  SRC_ZOEKT_* for the rest.

Gitserver no longer gets the settings, since the worker now queues index
jobs after fetches.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
The searchers now report readiness on the debug server, which fails as
soon as a shutdown starts, like the other services.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
With indexedSearch.enabled false, the frontend still defaults to Kubernetes
discovery of the indexed-search StatefulSet. Set INDEXED_SEARCH_SERVERS and
INDEXED_SEARCH_INDEXER to empty for it, unless frontend.env sets them.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
Neither the Zoekt indexer nor the searchers read DATA_DIR, and
SRC_FRONTEND_INTERNAL had its default value. The indexer's scratch
directory comes from TMPDIR, which stays.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
The Zoekt indexer now requires SRC_ZOEKT_INDEXER_SCRATCH_DIR instead of
defaulting to the temporary directory. Point it at /data/scratch on the
scratch volume.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
The indexer's scratch directory was a 20Gi emptyDir with no
ephemeral-storage request, too small for monorepos such as Chromium,
whose fetch and shards take 8 to 14 GB per job.

Each indexer pod now gets its own PersistentVolumeClaim, a generic
ephemeral volume of 100Gi by default, which Kubernetes deletes with the
pod. Its storage class defaults to a new <storageClass.name>-scratch
class, created like storageClass but with the Delete reclaim policy, so
the disk goes away on scale-down and rollouts instead of being retained
like the chart's other volumes. scratch.persistentVolume=false keeps an
emptyDir instead, with a matching ephemeral-storage request.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41
Both Zoekt workloads now render SRC_PRE_SHUTDOWN_PAUSE and
SRC_GRACEFUL_SHUTDOWN_TIMEOUT and take the usual preShutdownPause,
gracefulShutdownTimeout and terminationGracePeriodSeconds overrides.
The searcher no longer has its own 15 s drain, so its 60 s termination
grace and the check that it is at least 30 s are gone. The helpers
also accept a values map for nested services like zoekt.indexer.

Amp-Thread-ID: https://ampcode.com/threads/T-597f342f-9754-47be-8f3e-3c5ffc344e41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant